﻿#ifndef SOCKETMANAGER_H
#define SOCKETMANAGER_H

#include <QObject>
#include <QTcpSocket>
#include <QTcpServer>
#include <QVariant>
#include "dbmanager.h"

class SocketManager : public QObject
{
    Q_OBJECT
public:
    SocketManager();

    QTcpSocket* tcpSender = nullptr;
    QTcpSocket* tcpReceiver = nullptr;
    QTcpServer* tcpServer = nullptr;

    Q_INVOKABLE bool addOtherClient(QString, quint16, QVariantMap);
    Q_INVOKABLE bool initNetwork(qint16);
    Q_INVOKABLE bool sendMsg(QString, qint16, QVariantMap);
    bool recMsg(QString);

    bool sendSelfInfoData(QString);
    DBManager dbManager;

signals:
    void recMsgAddRect();
    void flushPage();

public slots:
    void slotRecMsgDataServer();
    void slotRecMsgDataSender();
    void slotNewConSocket();
};

#endif // SOCKETMANAGER_H
